Part Number Hot Search : 
00145 A512F 11000 2N5328 TDA8451A 50P10 X24012 HF25F
Product Description
Full Text Search
 

To Download PICAXE08 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  the PICAXE08 for beginners a basic introduction to the picaxe 08 w r itten by adrian s t eel
the picaxe is a very cheap and very versat ile programm a ble chip, which, with a little knowledge and im agination, can perf orm all sorts of useful and wonderful tasks. this course is aim e d at providi ng you with enough knowledge so that you feel comfortable with the chip and its programm i ng language. there are a lot of programming wor d s to learn, an in this cou r se we will be looking at the m o st useful ones. the chip uses a com puter and a sim p le programmi ng language to program it w ith. most versions of w i ndows wi ll be ok , including xp. your com p uter must have a useable com port to attach the programm i ng lead to. for those of you without compor ts, belkin m a ke an excellent usb to comport adapte r. the r e ar e othe rs but a lo t of them will not work with the picaxe. the belkin one works fine. the programming lead will need to be m a de up by you. instructions on h o w to do this are found later on in this w o rksheet. the soft ware. the software that is used by the picaxe is a free download fro m the website (www. rev-ed.co.uk) when it run s you will b e presen ted with an opti ons screen. here you will need to tell the programm e r which type of picaxe you are usin g. in this case choose picaxe-08 ( it m i ght already be selected) next you will have to tell the p r ogram which com por t your lead is plugg ed into. click the left hand button on s e rial port tab. any available co m ports will be shown. those tha t cannot be used are greyed o u t. select th e righ t com port. the chip the chip is an 8 pin device. of these 8 pins 5 are ?control' pins. to add to the confusion the programm a ble pins h a ve been num bered dif f e rently to th eir p o sition s on the chip ( s e e diagram below) note pin0 m u st always be an output a nd pin3 m u st always be an in put. the other pins 1,2,4, can be either in put or output. . 3 ? 4. 5 vol t s pin1 pin0 /serial out pin2 pin4 pin3 serial in + 5 6 7 8 4 3 2 1
the chip is powered up using chip pin1 to connect to positive and chip pin8 to connect to negative. 2 resistors connect to chip pin2 which is the input from the programm i ng lead. building the programmer look at your programmer overlay to see how the chip is wired up. place th e ov erlay sh eet o n to the b r eadboard. build the programm e r onto the breadboard, by pl acing the components thr ough the overlay into the board once you have built it, test it works by doing the f o llowing. connect the battery pack connect the programm i ng lead ( m a ke sure th at pin 3 on the lead plugs into the sam e row as chip-pin8 ) press f3 on the com puter keyboard.? you should get a downloa d window. if not check your connections. make sure the battery pack is switched on. flashing an led in order to flash an led we need to provide power to the led for a pe riod of tim e and then rem ove the power. we can do this using th e picaxe output pins. the command high sets a pin to po sitiv e. the c o mm and low sets a pin to negative. place a red led into th e breadboard so that the positiv e leg is in pi n1 and the negative leg is on the ground line w r ite the following program . note do not type th e text after the ***** this is to tell you what each line do es led flas her this program will flash an led on and off at half second intervals. start: **** a label used for program flow m a ke sure it has a colon (:) at the end of the line) high 1 **** sets pin1 to high puts a positive on pin1 ( turns led on) pause 500 **** the program pauses he re in milliseconds therefore 500 is half a secon d low 1 **** sets pin1 to low ( turns led off) pause 500 **** another half second delay goto start **** send the program back round to the first line
once you have type it in. download the program to the chip by pressing the f5 key . the download strip should appear and the su ccess alert should show once it has been successfully downloaded. the led should now flash. pulsout at first look you m i ght think that this comm and does the sam e job as the previous program . in som e respects it does, however it goes a bout it in a entirely different way. the syntax for the command is this?. pulsout pin, tim e where pin is the pin to which your device is attach ed i.e. and led and tim e is the length of the pulse in m i croseconds. click on the file dropdown m e nu a nd select new type in the following program start: ***** program label pulsout 1,50000 ***** send a pulse of half a second to pin 1 pause 500 ***** w ill pause for half a second goto start ***** loop program back round to the start press f5 to download the program to the chi p. can you see that the led flashes exactly the sam e as before. if you wish to check, open up the previous program wi ndow by m i nim i sing the window you have just types into and opening up the first progra m window. press f5 to download the program and see th e led flas h exactly as it did before. so far then apart from saving a few lines of c ode, pulsout seem s to be doing exactly the sam e job as out first program . now try this .. add a second led by placing in on the breadboard so that the positive leg is in pin2 and the negative leg is on the ground line . open a new program wi ndow and type in the following start: **** program label high 1 **** sets pin1 to high puts a positive on pin1 ( turns led on) high 2 **** sets pin2 to high puts a positive on pin1 ( turns led on) pause 500 **** the program pauses here in milliseconds low 1 **** sets pin1 to low ( turns led off) low 2 **** sets pin1 to low ( turns led off) pause 500 **** another half second delay goto start **** send the program back round to the first line
you can now see that b o th led?s flash a t the sam e ti m e . we are switching them both on at the sam e time, even thou gh they are on separate lines of code, a nd we are switching them off at the sam e time. now do this open up a new programm i ng window type in the following star t: pulsout 1,50000 pulsout 2,50000 pause 500 goto start download the program to your chip. watch the l e d?s flash. can you see the difference between the two program s now. in the first where we use the high command and low comma nd both led?s light at the sam e tim e and go off at the sam e ti m e . when we use pulsout each led gets a pu lse for the pred eterm i ned am ount of ti m e . as such they alternate. in m o st instances if you want to flash led ?s then use the high low c o mm and options. challenge number 1 by using the high and low commands, get the led?s to light up alternatingly. w r ite your code in the box below.
more outputs. of course the output p i n s will dr ive more than ju st led?s. m o tors, so leno ids, re lays e t c.. all can be driven by the chip. h o wever, the higher curre nt devices such as m o tors and relays need a transistor driver to pass the higher current. the diagram below shows how a relay could be connected to the picaxe a transistor driver chip uln2003 is a better option. it is a 16 pin ic which has 6 high current trans i sto r s b u ilt into it. i t can be used f o r m o st high curren t d e vices. se e the diagr a m below 13 14 8 7 6 5 12 11 10 9 4 3 1 2 16 15 picaxe pin1 m 6 pin1 r e l a y 6
inputs an input to a pin can either be a logic 1 (positive) or a logic 0 ( negative) depending on what it is your trying to do. the chip can detect a bu tton being pressed, or an ldr receiving light o r s h adow, a therm i stor getting hot or cold etc. we are going to hook up a push button and get a nd led to flash when the button is pressed. fit the pu sh button be tween pin3 and positiv e. fit a 10k resistor between pin3 and ground. we need both of these attached to pin3 as the re sistor will give us a ne gative ( logic 0) and the pushbutton will giv e us a positive ( logic 1) open up a new editor window and type the following star t: if pin3=1 then ledon if pin3=0 then ledoff goto start ledon: high 2 wait 5 l o w 2 goto start l e doff: l o w 2 goto start download the program (f5) and test it. if you push the button the led should light up stay lit for 5 seconds and then go out. if you do not push the button then the led should rem a in off let us look at what is going on if pin3=1 th en ledon this is tes tin g to see if pin 3 has a po sitiv e on it. it will g e t on e if the button is pus hed as the b u tton is con n ected to the positiv e. if the button is pressed the program will jum p to the lab e l ledon and run the program from that point. if pin3=0 th en ledof f this is tes tin g to see if pi n 3 has a negative on it. it will get one if the button is n o t pushed as the button is connected to the negative via the resis t or. if the button is not pressed the progr a m will jum p to the lbl ld f f d h f h i
challenge number 2 w r ite a program that will flash an led if a button is pushed. use the box below to write your program and use the programs you have writt en already to help you. challenge number 3 w r ite a program that will flash an led if a button is pushed, and light another steady, f the button is n o t pushed use the box below to write your program
soun d. the picaxe is capable of driving a speaker di rect. all you need to do is hook a speaker up to an output pin and use the correct command to get a noise out. syntax sound pin, (note, duration) i.e. sound 1,(57,1) this will p l ay the sound whose value is 57 for a d u ration of 1. note this can be in the range of 0 to 255, with 0 being no sound to 255 being a hiss. notes 1-127 are ascending notes and notes 128-255 are white noise. duration can be in the range of 1-255. now i have not had m u ch luck so far finding out what the duration actually is. but after som e e xperim e ntation have discov ered that 50 is about one second. experim e nt yourself with the duration to get a feel for it. you can play m o re than one note in the sam e statem ent. sound,(note,duration,note,durat ion,note,duration?..) for instan ce the f o llowin g line will play the notes a , b, c in turn ,each note lasting for 1 second sound,(49,50,54,50,57,50) list of notes a=49 a#=51 b=54 c=57 c#=61 d=65 d#=71 e=78 f=88 g=100 playing notes firstly hook up the piezo speaker to the chip. the negative if m a rked goes to the ground line and the positive if m a rked goes to pin2. open up anew editor window and type in the following sound 2, (57,50) this will p l ay the note c for about 1 s econd try experimenting with the duration. th en try experim e nting with the note. now try playing m o re than one not in the sam e statem ent. also try experim e nting with differing durations for the notes in the sam e statem ent. re m e mber if you want a rest ( period) in your tune then se t the note to 0 finally experim e nt with sounds above 128, white noise
for nex t loop the best way to experiment with the so und command is to use the for-next loop. for those of you who are not fam iliar with this co mmand i will explain it h e re. the for syntax is for variable = n1 to n2 what this means is we are going to run a count er which will start at n1 w h ich is a nu mber you will choos e, usually 1, an d then end at a hi gher nu mber n2, again which y ou will choo se. in order to keep track of this coun ter we need to s t ore it in a v a riab le . so the comm and m i ght look like this for b0=1 to 5 what this means is we are going to carry out a sequence 5 tim es and keep track of the count using the variable b0. in order to loop the prog ram round after each co unt we use the next command. so a program m i ght look like this for b0=1 to 5 print ?h ello ? next lets look at how that works. firstly when the program runs it sets b0 to 1. th en it goes on to the next line and prints hello then it goes to the next statem ent where it checks to see if the num ber stored in the variable b0 equals the higher number you se t which in this case is 5. if it doesn?t equal the higher num b er, the program loops back to the for statem ent. now as it runs through again it sets the variable b0 to 2. again it prints hel l o and again it goes to next to do a check. it will rep eat this pro cess until the nu mber st ored in the va riab le b0 does equal th e higher num b er set. so the abov e program will run th rou gh 5 tim es, each tim e printing hello, so you end up with 5 hello?s. note. unlike the norm a l com puter basic prog ramm ing language, you cannot actually print to the screen using the picaxe programm i ng language. you can however print to a l c d screen hooked up to the picaxe. but that is a more advanced skill. now because the num ber count is a variab le, we can use it to our advantage. instead of using the note num b er in our s ound command we can use a v a riab le in stead. the sam e for duration. we can use a vari able for the duration of our note.
more s o und by using a for-next loop we can quickly and easily program som e cool sound effects there are 127 notes that can be played. so in order for you to pl ay them all you would need to write the sound co mmand 127 tim es. however with a for next loop we can do it in 3 lines consider the program below for b0=1 to 127 sound 2,(b0,10) next w h at is hap p ening is tha t the f i r s t tim e th e program runs it sets the variable b0 to 1. in the next line we are using pin2 to play the s ound. the value of that sound is stored in the variable b0, which in this case is 1. and finally w e are playing that sound for a duration of 10. now because the prog ram count has not yet achi eved the high er num ber ( 127) the next part send it back to the beginning again. when the program runs through a second tim e the sound va lue will be 2. so that value of note will be p l ay ed. and so on and so on until th e count reaches th e h i gher num ber of 127, where th e program stops. what this means is we are playing a st eadily increasing note for a duration of 10. try it for yourself. open a anew program window and type in the program above. advanced for next loop we can extend the capabilitie s of the for next loop by altering the count. the f o llowing command will coun t in steps of 1 0 for b0=1 to 127 step 10 so the count will go 1 , 1 1, 21, 31 etc. the f o llowing command will coun t dow n in steps of 1 for b0=127 to 1 step ?1 the f o llowing command will coun t down in step s of 10 for b0=127 to 1 step ?10 try them yourself.
some good s ounds the following are a few good sounds to try. american police siren flash: for b2=100 to 125 sound 2,(b2,1) next for b2=125 to 100 step -1 sound 2,(b2,1) next goto flash british p o lice car siren star t: sound 2,(100,50) pause 100 sound 2,(85,50) pause 100 goto start twinkle twinkle sound 2,(57,50,57,50,80,50,80,50,85,50,85,50,80,100,74,50,74,50,71,50,71,50,64,50,64,50,57,100) rising t o ne for b0=1 to 127 sound 2,(b0,5) next falling tone for b0=127 to 1 step -1 sound 2,(b0,5) next experim e nt with the above values to get som e other effects.
there are a lot of other comm ands that the p i c axe uses. i suggest you visit the rev-ed site on the internet (www.rev-ed.co.uk) and download all the pdf f iles regarding the picaxe 08. the other commands are more specialist and refer to specific inputs and functions. below is a list of these comm ands to whet your appetite high sets a pin high low sets a pin low toggle toggle the state of an output pin output sets a pin as an output input sets a pin as an input reverse reverse the out put/input state of a pin pulsout sends a pulse out to a pin if ? then conditional program loop puslin measures the lengt h of an input to a pin sound sends a noise out to a pin pw m provides pulse width modulation ( go od for controlling the speed of a m o t o r) readadc read an analogue channel into a variable for..next conditional program loop branch jum p to an address specified goto jum p to a another p l ace in the program gosub tem porarily jum p to anothe r p l ace in the program then return return the return co mm and for gosub (let) perform variable m a them atics lookup look up data and store in a variable lookdown find targets m a tch and store in a v a riable ramdom generate a random number serout output serial data from out put pin serin input serial da ta to an input pin eeprom store data in eeprom be fore downloading a basic program read read data e e prom into a variable w r ite w r ite data into eeprom loca tion nap enter low power m ode for a short period ( up to 2.3 secs) sleep enter low power m ode for period up to 65535 secs end power down until rese t, an indef i nite sleep pause wait for up to 65535 m illi secs in m illi seconds wait wait for up to 65 seconds in seconds debug outputs variable data to pc via programm i ng lea d have fun wi th this chip. re m e m b er the only lim itation is your im agination. and if your not sure if it will work, then try it you w ill be surprised what effects y ou can get b y experim e ntation with the programm i ng language adrian steel director of electrotechnology rangitoto c o llege em ail steela@rangitoto.school.nz
connection di agrams positive sup p ly connect o r from c o m p uter ( se e bel o w) 10k resisto r 22k resistor negative supply out put 4 out put 3 out put 2 out put 1 out put 0


▲Up To Search▲   

 
Price & Availability of PICAXE08

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X